package me.sauce.folkpocket48.data.response

import io.reactivex.Flowable
import me.sauce.folkpocket48.data.local.sp.LoginManager
import me.sauce.folkpocket48.data.remote.NetFactory
import me.sauce.folkpocket48.data.remote.bean.request.LoginRequest
import me.sauce.folkpocket48.data.remote.bean.result.LoginResult

/**
 * @author sauceWu
 * @since 2018/2/13 11:08
 */

class LoginResponse {

    fun login(userName: String, password: String): Flowable<LoginResult.ContentBean> {
        return NetFactory.USER_API
                .postLogin(LoginRequest(password, userName))
                .map { return@map it.ContentBean() }
                .doOnNext { LoginManager.get().token = it.token }
    }


}
